<template>
  <div id="app">
    <transition mode="out-in">
      <keep-alive>
        <component :is="coms[currentIndex]"></component>
      </keep-alive>
    </transition>
    <div class="bu">
      <div
        :class="{ shu: true, active: currentIndex == index }"
        v-for="(item, index) in zu"
        :key="index"
        @click="handle(index)"
      >
        <div :class="{ iconfont: true, [item.icon]: true }"></div>
        <div class="zi">{{ item.text }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import Shou from "./components/Shouye.vue";
import One from "./components/One.vue";
import Dingdan from './components/Dingdan.vue'
export default {
  name: "App",
  components: {
    Shou,
    One,
    Dingdan,
  },
  data() {
    return {
      coms: [Shou, One, Dingdan, One],
      currentIndex: 0,
      zu: [
        { id: 1, icon: "icon-infenicon18", text: "首页" },
        { id: 2, icon: "icon-faxiandingdan", text: "爆爆团" },
        { id: 2, icon: "icon-zixun", text: "订单" },
        { id: 3, icon: "icon-yonghu", text: "我的" },
      ],
    };
  },
  methods: {
    handle(index) {
      this.currentIndex = index;
    },
  },
};
</script>

<style>
* {
  padding: 0;
  margin: 0;
}
.bu {
  height: 60px;
  border-top: 2px solid #eee;
  border-bottom: 2px solid #eee;
  position: fixed;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  background-color: white;
}
.shu {
  text-align: center;
  margin-top: 10px;
}
.iconfont {
  font-size: 22px;
}
.active {
  color: red;
}
.v-enter{
  opacity: 0;
}
.v-enter-active{
  transition: all 1s;
}
.v-enter-to{
  opacity: 1;
}
v-leave{
  transform: scale(1);
}
v-leave-active{
  transition:all 1s
}
v-leave-to{
  transform: scale(0);
}
</style>
